package barcode

import (
	"encoding/base64"
	qrcode "github.com/skip2/go-qrcode"
	"image/color"
)

func CreateBase64(content string, R, G, B, A uint8) (base64Str string, err error) {
	var q *qrcode.QRCode
	q, err = qrcode.New(content, qrcode.Medium)

	q.ForegroundColor = color.NRGBA{R, G, B, A}
	q.BackgroundColor = color.White

	var png []byte
	png, err = q.PNG(256)

	base64Str = "data:image/png;base64," + base64.StdEncoding.EncodeToString(png)
	return base64Str, nil
}
